package org.colcon.web.model;

import java.util.HashMap;
import java.util.Map;

import org.colcon.web.model.framework.IBallot;

public class Ballot extends Item implements IBallot
{
	public String getType(){return "ballot";}
	
	private static final long serialVersionUID = 8988178703134546530L;
	
	private static final String
	
		// arguments
		USER = "user",
		VALUE = "value";
	
	public Ballot()
	{
		this(new HashMap<String, String>());
	}
	
	public Ballot(Map<String, String> args)
	{
		this(
				args.get(PARENT), 
				args.get(USER), 
				args.get(VALUE)
		);
	}
	
	public Ballot(String parent, String user, String value)
	{
		//TODO: don't store by voter id
		
		// stored by id of voter
		super(parent, user);

		setArg(VALUE, value);
	}
	
	public String getGroup()
	{
		return Group.pathToGroup(getParentPath());
	}
	
	public String getUser()
	{
		return getId();
	}
	
	public String getValue()
	{
		return getArg(VALUE);
	}
}
